﻿<!--#include file="include/config.asp"-->
<!--#include file="include/conn_f.asp"-->
<!--#include file="top.asp"-->
<!--#include file="left.asp"-->
<center>
    <%
If Session("cust_id")="" Then
    Response.Write "请先登录网站!"
    Response.End
End If
Public Function OnlyNumber(StrChar)
    Const AllChar = "0123456789"
    Const AllNum = 10
    Dim ReplaceSomeChar
    Dim CharLenngth
    Dim StrChar1
    CharLenngth =  Len(StrChar)
    For j=1 To CharLenngth
        ReplaceSomeChar = Mid(StrChar,j,1)
        'Response.Write(ReplaceSomeChar & "<br />")
        If InStr(AllChar,ReplaceSomeChar)<>0  Then
            If Not (ReplaceSomeChar=0 and len(StrChar1)=0) Then			
             StrChar1 =  StrChar1 & ReplaceSomeChar
            End If
        End If
    Next
    'Response.Write(StrChar1)
    OnlyNumber = StrChar1
End Function 

strVcode2=saferequest("strVcode2",0)
sql="select pcl_id,vercode from phone_confirm_log where cust_id="&Session("cust_id")&" and plc_status=0 order by pcl_id desc"
Set rs=conn.execute(sql)
If Not rs.eof Then
    pcl_id=rs("pcl_id")
    strVcode1=rs("vercode")
Else
    Response.Write "你还没有发出电话验证请求!"
    Response.End
End If

Response.Write "您填写的4个数字是:"&strVcode2&"<br />"


If cint(strVcode1)=cint(strVcode2) Then
    Response.Write "<font size='3' color='green'>电话验证成功!</font>"

    sql="select * from customer where cust_id="&Session("cust_id")
    Set rs=conn.execute(sql)
    If Not rs.eof Then
        strPhone=rs("phone")
        buytimes=rs("buytimes")
        verify_method=rs("verify_method")
    Else
        Response.Write "错误,没有此客户"
        Response.End
    End If 
    strPhone = OnlyNumber(strPhone)
    strPhone = "%2B"&strPhone
    
    strLic = "1yI6AqYf1rwa"
    Host = "https://www.maxmind.com/app/phone_id_http"
    Data = "?l=" & strLic & "&phone=" & strPhone	
    Set xml = Server.CreateObject("Microsoft.XMLHTTP")
    xml.open "POST", Host & Data & "", false
    xml.send ""   
    Xmlresponse = xml.responseText   
    Set xml = Nothing 

    If Not Xmlresponse = "" Then
        If InStr(Xmlresponse, "phoneType")<>0 Then
            phoneType = mid(Xmlresponse,InStr(Xmlresponse, "phoneType")+10,1)
        Else
            phoneType=-1
        End If
    Else
       phoneType=-1
    End If
    
    If phoneType>2 Then
        sql="update customer set isactive=2,phone_confirmed=1,phone_type="&phoneType&" where cust_id="&Session("cust_id")
        isactive=2
    ElseIf phoneType=2 Then
        sql="update customer set isactive=1,phone_confirmed=1,phone_type="&phoneType&",credit_limit=credit_month+250 where cust_id="&Session("cust_id")
        isactive=1
    ElseIf phoneType=1 Then
        sql="update customer set isactive=1,phone_confirmed=1,phone_type="&phoneType&",credit_limit=credit_month+500 where cust_id="&Session("cust_id")
        isactive=1
    Else
        sql="update customer set isactive=1,phone_confirmed=1,phone_type="&phoneType&" where cust_id="&Session("cust_id")
    End If
    conn.execute sql

    sql="update phone_confirm_log set plc_status=1,phone_type="&phoneType&",answercode='"&strVcode2&"' where pcl_id="&pcl_id
    conn.execute sql
Else
    Response.Write "<font size='3' color='red'>电话验证失败!</font><br />"
    Response.Write "您填写的数字不正确."

    sql="update customer set phone_confirmed=3 where cust_id="&Session("cust_id")
    conn.execute sql
    
    sql="update phone_confirm_log set plc_status=2,answercode='"&strVcode2&"' where pcl_id="&pcl_id
    conn.execute sql
End If

    %>
    
    <!--#include file="bottom.asp"-->
